package ch.sv7.tool.dbmanager.db.fix;

import ch.sv7.tool.dbmanager.db.ColumnSchema;
import ch.sv7.tool.dbmanager.db.SchemaElement;
import ch.sv7.tool.dbmanager.db.dialect.DialectException;

/**
 * TODO: Document me!
 *
 * @author svt
 *
 */
public class CreateColumnFix extends AbstractSchemaFix implements SchemaFix {


	private ColumnSchema columnSchema;

	/**
	 * @param missingColumnDifference
	 */
	public CreateColumnFix(ColumnSchema columnSchema) {
		super();
		this.columnSchema = columnSchema;
	}

	public SchemaElement getActionTarget() {
		return columnSchema;
	}
	
	public String getSQLFix() throws DialectException {
		String ddl = "\n-- Add column Fix \n";
		ddl += getDialect().getAddColumnDDL(columnSchema);
		return ddl;
	}

	public int getPriority() {
		return SchemaFix.PRIORITY_COLUMN_CREATION;
	}

	public int getAction() {
		return ACTION_CREATE;
	}

	public String getDescription() {
		return "Add column " + columnSchema + " to table " + columnSchema.getTable().getName();
	}


	
}
